package com.atguigu.lease.common.utils;

import java.util.Random;

/**
 * @ClassName: CodeUtil
 * @Description:
 * @Author: yangchengbao
 * @Create: 2025/1/9 9:28
 * @Version: 1.0
 */
public class CodeUtil {

    /**
     * @param length 验证码长度
     * @Desceription: 随机生成指定长度的验证码
     * @Return: java.lang.String
     * @Author: yangchengbao
     * @Date: 2025-01-09 09:01:35
     */
    public static String getRandomCode(int length) {
        StringBuilder builder = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            builder.append(random.nextInt(10));
        }
        return builder.toString();
    }
}
